package com.Action;

import java.util.List;
import java.sql.SQLException;
import java.util.ArrayList;

import com.implement.InputDB;
import com.jdbc.Jdbc;
import com.project.bean.*;

public class SalesInputDB implements InputDB {

	

	@Override
	public int InputDB(List  obj) {
		List<Sales> fsl = new ArrayList<>();
		fsl = obj;
		
		
		for(Sales s:fsl) {
			
			String id =s.getId();
			String cname=s.getChinesename();
			String ename=s.getEnglishname();
			String sex=s.getSex();
			String birthday = s.getBirthday();
			String reservation=s.getReservation();
			String attend = s.getAttend();
			String messagefrom = s.getMessagefrom();
			String marketman = s.getMarketman();
		    String counselor =s.getCounselor();
			String pcounselor = s.getPhonecounselor();
			String distributionstate =s.getDistributionstate();
			String distributiontime = s.getDistributiontime();
			String phone1=s.getPhone1();
			String phone2=s.getPhone2();
			String remarks=s.getRemarks();
			String username = s.getUsername();
			String insert = "insert into sales(id, chinesename,englishname,sex,birthday,reservation,attend,messagefrom,marketman,counselor,phonecounselor,distributionstate,distributiontime"
					+ ",phoen1,phone2,remarks,username)values('"+id+"','"+cname+"','"+ename+"',"
							+ "'"+sex+"','"+birthday+"','"+reservation+"','"+attend+"','"+messagefrom+"','"+marketman+"',"
									+ "'"+counselor+"','"+pcounselor+"','"+distributionstate+"','"+distributiontime+"','"+phone1+"','"+phone2+"','"+remarks+"','"+username+"')";
	        System.out.println(insert);
			Jdbc j1 = null;
		
			try {
				j1= new Jdbc(insert);
				
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				
				e.printStackTrace();
				return 0;
			}
			
				
			
		}
		return 1;
	}


	

	

}

